<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
	// 7、`Promise.race`方法: (promises) => {}
	// (1) promises: 包含n个promise的数组
	// 说明: 返回一个新的promise, 第一个完成的promise的结果状态就是最终的结果状态
	const p1 = new Promise((resolve,reject)=>{
		setTimeout(()=>{
			resolve(1);
		},90)
	})
	const p2 = new Promise((resolve,reject)=>{
		setTimeout(()=>{
			reject(2);
		},30)
	})
	const p3 = new Promise((resolve,reject)=>{
		setTimeout(()=>{
			reject(3);
		},60)
	})
	const p4 = new Promise((resolve,reject)=>{
		setTimeout(()=>{
			resolve(4);
		},100)
	});
	Promise.race([p1,p2,p3,p4]).then(value=>{
		console.log("成功回调",value);
    },reason=>{
		console.log("失败回调",reason);
    })
</script>
</html>